﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using FXSStation.Modules.SharedInfrastructureModule.BusinessClasses.Orders;
using System.Collections.ObjectModel;

namespace FXSStation.Modules.SharedInfrastructureModule.Extentions.Converters
{
    public class BuyOrdersConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return Binding.DoNothing;
            else
            {
                ObservableCollection<OrderBase> orders = (ObservableCollection<OrderBase>)value;
                if (orders != null)
                {
                    return orders.Where(x => x.Type == OrderType.BuyOrder);
                }
                else
                    return Binding.DoNothing;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
